/*
 *
 * Copyright (C) 2012 Mauricio Garcia
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef _ADMINISTRATION_H_
#define _ADMINISTRATION_H_

#include "msocket.h"
#include <string.h>

// Structure to save the connection
struct peer{
  struct sockaddr_in addr;
  int peer;
  int peerOther;
  char id[16];
  int lenID;
};

// Linked list
struct nodeList{
  struct peer key;
  struct nodeList *next;
};

// Insert in the hash table
int insertPeer(struct nodeList *sockList[], int peer,
	       struct sockaddr_in* sockaddr, char id[]);
  
// Get from the hash table
struct peer* getPeer(struct nodeList *sockList[], int peer);

// Remove from the hash table
int removePeer(struct nodeList *sockList[], int peer);

// Free the memory of a list
void freeList(struct nodeList **node);

#endif /*_ADMINISTRATION_H_*/
